package com.hansen.library.ui.activity;

import android.annotation.TargetApi;
import android.os.Build;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

import com.hansen.library.R;

/**
 * 沉浸 activity 基类
 *
 * Created by han on 2019/6/10 0010.
 */

public abstract class BaseTranBarActivity extends BaseActivity {

    @Override
    protected int getResID() {

        setTranslucentStatus();
        setStatusBarColor();

        return getTranBarResID();
    }

    public abstract int getTranBarResID();

    @TargetApi(Build.VERSION_CODES.KITKAT)
    private void setTranslucentStatus() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            // Translucent status bar
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        }
    }

    @TargetApi(Build.VERSION_CODES.M)
    protected void setStatusBarColor() {
        //修改为深色，因为我们把状态栏的背景色修改为主题色白色，默认的文字及图标颜色为白色，导致看不到了。
        getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
    }
}